#Include <WinAPI.au3>
 
Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

Func GetWinSize($Title)

	$var = WinList($Title)
	Local $hWnd;
	For $i = 1 to $var[0][0]
		; Only display visble windows that have a title
		If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
			;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
			$hWnd = $var[$i][1]
		EndIf
	Next
	local $result[2]

	$result[0] = _WinAPI_GetWindowHeight($hWnd)
	$result[1] = _WinAPI_GetWindowWidth($hWnd)

	return $result
EndFunc

Func LookUpSome($Title)
	LookUp($Title,100)
EndFunc

Func LookDownSome($Title)
	LookDown($Title,100)
EndFunc

Func LookUp($Title, $amount)
	
	dim $WinSize = GetWinSize($Title)
	dim $Y = ($WinSize[0] / 2) ;center screen vertical
	dim $X = ($WinSize[1] / 2) ;center screen horizontal
	Sleep(1000)
	MouseMove( $X,$Y, 1) 
	Sleep(1000)
	MouseDown("right")
	Sleep(100)
	MouseMove(  $X ,$Y - $amount, 1) 
	Sleep(1000)
	MouseUp("right")
EndFunc

Func LookDown($Title, $amount)
	
	dim $WinSize = GetWinSize($Title)
	dim $Y = ($WinSize[0] / 2) ;center screen vertical
	dim $X = ($WinSize[1] / 2) ;center screen horizontal
	Sleep(1000)
	MouseMove( $X,$Y, 1) 
	Sleep(1000)
	MouseDown("right")
	Sleep(100)
	MouseMove(  $X ,$Y + $amount, 1) 
	Sleep(1000)
	MouseUp("right")
EndFunc

Func ZoomInMax()
	ZoomIn(25)
EndFunc

Func ZoomOutMax()
	ZoomOut(25)
EndFunc

Func ZoomIn($amount)
	Local $i = 0
	while $i < $amount
		$i = $i + 1
		Send("{NUMPADADD}")
		sleep(100)
	wend
EndFunc

Func ZoomOut($amount)
	Local $i = 0
	while $i < $amount
		$i = $i + 1
		Send("{NUMPADSUB}")
		sleep(100)
	wend
EndFunc

Func TurnLeftSome()
	TurnLeft(8)
EndFunc

Func TurnLeft($amount)
	dim $turncount = $amount
	if $turncount > 0 then
		while $turncount > 0
			send("aaa")
			;sleep(50)
			Sleep(5)
			$turncount=$turncount-1
		wend
	Else
		Send("{a down}") ;Holds the d key down
		Sleep($amount * 50)
		Send("{a up}") ;Releases the d key
	endif
EndFunc

Func TurnRightSome()
	TurnRight(8)
EndFunc

Func TurnRight($amount)
	dim $turncount = $amount
	if $turncount > 0 then
		while $turncount > 0
			send("ddd")
			;sleep(50)
			Sleep(5)
			$turncount=$turncount-1
		wend
	Else
		Send("{d down}") ;Holds the d key down
		Sleep($amount * 50)
		Send("{d up}") ;Releases the d key
	EndIf
EndFunc

Func MoveForwadSome()
	MoveForward(100) 
EndFunc

Func MoveForward($amount)
	Send("{w down}") ;Holds the d key down
	Sleep($amount)
	Send("{w up}") ;Releases the d key
EndFunc

Func MoveBackSome()
	MoveBack(100)
EndFunc

Func MoveBack($amount)
	Send("{s down}") ;Holds the d key down
	Sleep($amount)
	Send("{s up}") ;Releases the d key
EndFunc

Func Max($one, $two)
	if $one > $two Then
		return $one
	Else
		return $two
	endif
EndFunc

Func Min($one, $two)
	if $one < $two Then
		return $one
	Else
		return $two
	endif
EndFunc

Func LootCenterScreen()
	Local $WinTitle = "World of Warcraft"
	Local $WinSize = GetWinSize($WinTitle)
	Local $LootY = ($WinSize[0] / 2)  + 200 ;vertical
	Local $LootX = ($WinSize[1] / 2)  		;horizontal

	Sleep(5000)
	MouseMove($LootX, $LootY, 1) 
	Sleep(1000)
	MouseDown("right")
	Sleep(100)
	MouseUp("right")
	Sleep(3000)
EndFunc


Func TurnWithMouse($direction, $amount)
	dim $WinTitle = "World of Warcraft"
	dim $WinSize = GetWinSize($WinTitle)
	
	dim $LootY = ($WinSize[0] / 2)   ;vertical
	dim $LootX = 0   ;horizontal

	if $direction = "LEFT" Then
		$LootX = $WinSize[1]
	endif
	
	MouseMove($LootX, $LootY, 1) 
	Sleep(50)
	MouseDown("right")
	Sleep(50)
	if $direction = "LEFT" Then
		MouseMove($LootX - $amount, $LootY, 1) 
	Else
		MouseMove($LootX + $amount, $LootY, 1) 
	endif
	Sleep(1000)
	MouseUp("right")
	Sleep(50)
EndFunc
	

